<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-remove"></li></button>
	<h5 class="modal-title">修改密码</h5>
</div>

<div class="modal-body">

	<form id="user-form" name="user-form" class="form-horizontal">

		<div class="box-body">

			<div class="col-md-7">
				<div class="form-group">
					<label for="telphone" class="col-sm-4 control-label">原密码</label>

					<div class="col-sm-7">
						<input type="password" class="form-control" id="pas" name="pas" placeholder="输入原密码">
					</div>
				</div>
				<div class="form-group">
					<label for="telphone" class="col-sm-4 control-label">新密码</label>

					<div class="col-sm-7">
						<input type="password" class="form-control" id="pas2" name="pas2" placeholder="输入新密码">
					</div>
				</div>
				<div class="form-group">
					<label for="telphone" class="col-sm-4 control-label">确认新密码</label>

					<div class="col-sm-7">
						<input type="password" class="form-control" id="pas3" name="pas3" placeholder="再次输入新密码" required="required">
					</div>
				</div>

			</div>
			<div class="col-md-4">
				<div class="form-group">
					<label for="loginName" class="col-sm-9 control-label" id="username">尊敬的用户你好！</label>
				</div>
				<div class="form-group">
					<div class="col-sm-7 control-label">
						<textarea name="msg" rows="4" cols="40" style="border: none;">      为保障您下次可以顺利登陆该权限管理系统，请您牢记密码！ 如忘记密码，可退出登录,至登录页面选择忘记密码，以找回密码！</textarea>
					</div>
				</div>
				<div class="form-group" style="vertical-align: middle;">
					<label class="col-sm-6 control-label">
						<button type="button" class="btn btn-primary" data-btn-type="cancel" data-dismiss="modal">取消</button>
					</label>
					<label class="col-sm-4 control-label">
						<button type="button" class="btn btn-primary" data-btn-type="save">提交</button>
					</label>
				</div>
			</div>
		</div>
	</form>

</div>
<script>
	$(function() {
		var user = sessionStorage.getItem('user');
		$("#username").html('尊敬的用户' + user + '您好！');
		$(".btn-primary").click(function() {
			//			console.log($("#nickName").val());
			$.ajax({
				type: "post",
				url: "/password/update",
				data: {
					username: user,
					psw: $("#pas").val(),
					psw2: $("#pas2").val()
				},
				success: function(data) {
					data = JSON.parse(data);
					//					console.log(data.code);
					if(data.code == 0) {
						alert("密码修改成功");
						location.href = "/user/show";
						//						session.removeAttribute("userinformation");
					} else {
						alert(data.message);
					}
				},
				error: function(er) {
					console.log(er);
				}
			});
		});
	});
</script>